<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>2.Map类型增删改查操作</title>
</head>

<body>
  <script>
    let obj = {
      name: "后盾人"
    };
    let map = new Map();
    map.set(obj, "houdunren.com");
    map.set("name", "hdcms.com");
    console.log(map);//Map(2) {{…} => 'houdunren.com', 'name' => 'hdcms.com'}
    // 键使用的是引用地址，用同样的值，引用地址不同的键不能获得同样的数据
    // 使用键获取指定值
    console.log(map.get(obj)); // houdunren.com
    console.log(map.get({
      name: "后盾人"
    })); // undifined
    //是否包含key 为name的元素
    console.log(map.has("name")); // true
    // 删除指定元素
    console.log(map.delete(obj)); // true
    console.log(map);//Map(1) {'name' => 'hdcms.com'}
    //清空
    console.log(map.clear());//undifined
    console.log(map);//Map(0) {size: 0}
    
  </script>
</body>

</html>